package com.design.classroommanagement.admin

import com.design.classroommanagement.Pages
import com.design.classroommanagement.api.Role
import com.design.classroommanagement.databinding.ActivityAdminMyBinding
import com.design.classroommanagement.manager.UserAccountManager
import com.laughing.lib.base.BaseFragmentNoVM
import com.laughing.lib.utils.clickWithTrigger
import com.laughing.lib.utils.finishAllActivities
import com.laughing.lib.utils.openPage
import kotlinx.android.synthetic.main.activity_admin_my.*

class AdminMyFragment : BaseFragmentNoVM<ActivityAdminMyBinding>() {
    override fun initCompleted() {
        binding.apply {
            rl_alogout.clickWithTrigger {
                UserAccountManager.logout()
                finishAllActivities()
            }

            teacherLL.clickWithTrigger {
                openPage(Pages.TEACHER_LIST) {
                    withSerializable("role", Role.teacher)
                }
            }

            studentLL.clickWithTrigger {
                openPage(Pages.TEACHER_LIST) {
                    withSerializable("role", Role.student)
                }
            }

            courseLL.clickWithTrigger {
                openPage(Pages.UpdatePasswordFragment)
            }

            binding.pwdUpdateRl.clickWithTrigger {
                openPage(Pages.UpdatePasswordFragment)
            }

            val user = UserAccountManager.user ?: return
            nameTv.text = user.name


        }
    }
}